package com.yl.chainStore.payrule.item

import com.baomidou.mybatisplus.annotation.EnumValue
import com.fasterxml.jackson.annotation.JsonValue
import com.yl.chainStore.payrule.item.entity.BuyAndDiscountRule
import com.yl.chainStore.payrule.item.entity.DefaultItemRule
import com.yl.chainStore.payrule.item.entity.MoneyToMoneyTicketRule

enum class ItemRuleTypeEnum(@EnumValue val code: Int, @JsonValue val typeName: String, val clazz:Class<out ItemRule>) {

	MANUAL_DISCOUNT(1,"手动划价", DefaultItemRule::class.java),

	BUY_AND_DISCOUNT_RULE(2,"满减优惠", BuyAndDiscountRule::class.java),

	MONEY_TO_MONEY_TICKET_RULE(3,"抵用券", MoneyToMoneyTicketRule::class.java),



	DEFAULT(99,"默认", DefaultItemRule::class.java);

	companion object {
		fun getEnum(d: Int?): ItemRuleTypeEnum {
			return values()
				.find { it.code == (d ?: return DEFAULT) } ?: DEFAULT
		}
	}
}


